package com.sdkj.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class LoggerUtils {

	private Logger logger;

	
	/**
	 * 构造方法，初始化Log4j的日志对象
	 */
	private LoggerUtils(Logger newlogger) {
		logger = newlogger;
	}

	/**
	 * 获取构造器，根据类初始化Logger对象
	 * 
	 * @param Class
	 *            Class对象
	 * @return Logger对象
	 */
	public static LoggerUtils getLogger(Class classObject) {
		return new LoggerUtils(LoggerFactory.getLogger(classObject));
	}

	/**
	 * 获取构造器，根据类名初始化Logger对象
	 * 
	 * @param String
	 *            类名字符串
	 * @return Logger对象
	 */
	public static LoggerUtils getLogger(String loggerName) {
		return new LoggerUtils(LoggerFactory.getLogger(loggerName));
	}

	public void debug(String str) {
		logger.debug(str);
	}

	public void info(String str) {
		logger.info(str);
	}

	public void warn(String str) {
		logger.warn(str);
	}

	public void error(String str) {
		logger.error(str);
	}
	
	public void error(String str, Throwable e) {
		logger.error(str, e);
	}

	public String getName() {
		return logger.getName();
	}

	public Logger getLogger() {
		return logger;
	}

	public boolean equals(LoggerUtils newlogger) {
		return logger.equals(newlogger.getLogger());
	}
}